package com.yf.repo.modules.qu.dto;

import com.yf.base.api.annon.Dict;
import com.yf.system.utils.HtmlUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
* <p>
* 问题题目请求类
* </p>
*
* @author 聪明笨狗
* @since 2020-05-25 13:23
*/
@Data
@ApiModel(value="问题题目", description="问题题目")
public class QuDTO implements Serializable {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "题目ID", required=true)
    private String id;

    @Dict(dicCode = "id", dicText = "title", dictTable = "el_repo")
    @ApiModelProperty(value = "所属题库")
    private String repoId;
    private String repoId_dictText;

    @ApiModelProperty(value = "所属章节")
    @Dict(dicCode = "id", dicText = "title", dictTable = "el_repo_chapter")
    private String chapterId;
    private String chapterId_dictText;

    @Dict(dicCode = "qu_type")
    @ApiModelProperty(value = "题目类型", required=true)
    private String quType;
    private String quType_dictText;

    @Dict(dicCode = "qu_level")
    @ApiModelProperty(value = "1普通,2较难", required=true)
    private String level;
    private String level_dictText;

    @ApiModelProperty(value = "题目内容")
    private String content;

    @ApiModelProperty(value = "整题解析")
    private String analysis;

    @ApiModelProperty(value = "是否子题目", required=true)
    private Boolean child;

    @ApiModelProperty(value = "组合题ID")
    private String refId;

    @ApiModelProperty(value = "子题目排序", required=true)
    private Integer sort;

    @ApiModelProperty(value = "填空题按序", required=true)
    private Boolean answerOrder;

    @ApiModelProperty(value = "部门编码")
    private String deptCode;

    @ApiModelProperty(value = "创建时间", required=true)
    private Date createTime;

    @ApiModelProperty(value = "更新时间", required=true)
    private Date updateTime;

    @ApiModelProperty(value = "创建人", required=true)
    private String createBy;

    @ApiModelProperty(value = "修改人", required=true)
    private String updateBy;

    @ApiModelProperty(value = "数据标识", required=true)
    private Integer dataFlag;

    @ApiModelProperty(value = "ABC标签", required=true)
    private String tag;

    @ApiModelProperty(value = "内容文字", required=true)
    private String contentText;

    @ApiModelProperty(value = "知识点",required = true)
    private String knowledgePoint;

    /**
     * 获取文本
     * @return
     */
    public String getContentText(){
        if(StringUtils.isBlank(this.content)){
            return this.id;
        }

        String text =  HtmlUtils.splitAndFilterString(this.content, 160);
        if(StringUtils.isBlank(text)){
            return this.id;
        }
        return text;
    }
}
